<?php

namespace app\health\service;

use app\health\library\notice\DingTalk;

/**
 * 系统通知服务
 * @Author 张旭鹏
 * @DateTime 2023-07-11
 */
class SystemNoticeService
{
    /**
     * 开发人员手机号
     */
    public const DEVELOP_PEOPLE = [15511301855];

    public const OPERATE_PEOPLE = ['15511301855'];

    /**
     * 发送开发信息
     * @param $title
     * @param $content
     * @param boolean $atAll
     * @param int $delay
     * @return true
     * @Author 张旭鹏
     * @DateTime 2023-07-11
     */
    public static function develop($title, $content, bool $atAll = false, int $delay = 0): bool
    {
        if (request()->ip() === '127.0.0.1') {
            $dingTalk = new DingTalk('test');
        } else {
            $dingTalk = new DingTalk();
        }
        $dingTalk = $dingTalk
            ->at(self::DEVELOP_PEOPLE, $atAll)
            ->setMarkdownMessage($title, $content);
        queue('\app\health\job\SystemNoticeJob@delayMessage', ['ding_talk' => serialize($dingTalk)], $delay, 'health');
        return true;
    }
}
